@use "../../css/vars/colors" as colors;

.wrapper{
  position: relative;
  z-index: 0;

  &:has([aria-expanded="true"]) {
    z-index: 1;
  }
}

.innerWrapper {
  position: relative;
  display: flex;
  overflow: hidden;
  flex-direction: column;
  padding: var(--size__350);
  padding-top: var(--size__350);
  border: 1px solid var(--color__black--150);
  border-radius: var(--size__100);
  margin: var(--size__250);
  margin-right: 0;
  background-color: color-mix(in srgb, var(--color__white) 75%, var(--color__black--050));
  text-align: left;
  transition: all 200ms cubic-bezier(0.65, 0, 0.35, 1);

  .isWithoutProgress & {
    padding-bottom: var(--size__200);
  }

  &.isClickable {
    cursor: pointer;

    &:hover,
    &:focus-visible  {
      border: 1px solid var(--color__black--200);
      background-color: var(--color__black--050);
    }
  }

  .isStarting & {
    cursor: default;
  }

  .isPending & {
    cursor: default;
  }

  .wrapper:first-child & {
    margin-top: 0;
  }
}

.header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--size__200);
  line-height: 1;
}

.name {
  position: relative;
  z-index: 2;
  overflow: hidden;
  margin: 0;
  color: var(--color__black--700);
  font-size: var(--text__small);
  font-weight: 600;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;

  .innerWrapper.isClickable:hover &,
  .innerWrapper.isClickable:focus-visible & {
    .isActive & {
      color: var(--color__blue--800);
    }

    .isCompleted & {
      color: var(--color__green--800);
    }

    .isError & {
      color: var(--color__red--800);
    }

    .isPaused & {
      color: var(--color__black--800);
    }

    .isInterrupted & {
      color: var(--color__yellow--800);
    }
  }
}

.subMeta {
  position: relative;
  z-index: 3;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  margin-left: var(--size__350);
  color: var(--color__black--600);
  font-size: var(--text__small);

  .wrapper:hover & {
    display: none;
  }
}

.metaPrimary {
  display: flex;
  overflow: hidden;
  flex-shrink: 1;
  align-items: center;
}

.status {
  display: flex;
  overflow: hidden;
  flex-shrink: 1;
  align-items: baseline;
}

.primaryStatus {
  flex-grow: 0;
  flex-shrink: 0;
  margin-right: var(--size__150);

  .isActive & {
    color: var(--color__blue--700);
  }

  .isCompleted & {
    color: var(--color__green--700);
  }

  .isError & {
    color: var(--color__red--700);
  }

  .isPaused & {
    color: var(--color__black--700);
  }

  .isInterrupted & {
    color: var(--color__yellow--700);
  }
}

.tertiaryStatus {
  overflow: hidden;
  flex-grow: 1;
  flex-shrink: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta {
  position: relative;
  z-index: 3;
  display: flex;
  height: 1.75rem; // Height of action buttons
  justify-content: space-between;
  font-size: var(--text__small);
}

.percentComplete {
  flex-grow: 0;
  flex-shrink: 0;
  font-weight: 600;
}

.secondaryStatus {
  display: flex;
  flex-grow: 0;
  flex-shrink: 0;
  align-items: center;
  margin-right: var(--size__150);
  font-weight: 600;

  .isCompleted & {
    color: var(--color__green--650);
  }

  .isActive & {
    color: var(--color__blue--650);
  }

  .isPaused & {
    color: var(--color__black--650);
  }

  .isInterrupted & {
    color: var(--color__yellow--650);
  }

  .isError & {
    color: var(--color__red--650);
  }
}

.statusDescription {
  overflow: hidden;
  flex-grow: 1;
  flex-shrink: 1;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.statusDescriptionIcon {
  margin-right: var(--size__100);

  .isCompleted & {
    color: var(--color__green--500);
  }

  &.spinner {
    animation: spinnerRotate 2s linear infinite;
  }
}

.statusInformation {
  display: flex;
  align-items: center;
  margin: 0;
  font-size: var(--text__smaller);
}

.statusInformationTooltip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: var(--size__150);
  color: var(--color__black--600);
  cursor: default;
  text-decoration: underline;

  &:hover {
    color: var(--color__black--700);
  }
}

.statusInformationIcon {
  margin-right: var(--size__050);
  color: var(--color__black--650);
}

.hasErrorsIcon {
  margin-right: var(--size__100);
  color: var(--color__red--550);
}

.metaSecondary {
  position: fixed;
  display: flex;
  flex-shrink: 0;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  padding-left: var(--size__100);
  opacity: 0;
  pointer-events: none;
  user-select: none;
  visibility: hidden;

  &:focus-within,
  .isDropdownActive &,
  .innerWrapper:hover &,
  .innerWrapper:focus-visible & {
    position: relative;
    display: flex;
    width: auto;
    animation: metaSecondaryShow 500ms forwards var(--animation__spring);
    opacity: 1;
    pointer-events: all;
    user-select: initial;
    visibility: visible;
  }
}

.action {
  margin-right: var(--size__200);

  &:last-child {
    margin-right: 0;
  }
}

.progress {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 0;
  left: 0;
}

.progressBackground {
  position: absolute;
  z-index: 0;
  inset: 0 100% 0 0;
  transition: all 250ms cubic-bezier(0.65, 0, 0.35, 1);

  .isActive & {
    background-color: var(--color__blue--050);

    .wrapper:hover & {
      background-color: var(--color__blue--100);
    }
  }

  .isError & {
    background-color: var(--color__red--050);

    .wrapper:hover & {
      background-color: var(--color__red--100);
    }
  }


  .isPaused & {
    background-color: var(--color__black--050);

    .wrapper:hover & {
      background-color: var(--color__black--100);
    }
  }

  .isInterrupted & {
    background-color: var(--color__yellow--050);

    .wrapper:hover & {
      background-color: var(--color__yellow--100);
    }
  }
}

@keyframes metaSecondaryShow {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}


@keyframes spinnerRotate {
  from {
    transform:rotate(0deg);
  }

  to {
    transform:rotate(360deg);
  }
}
